/*
 * board.h
 *
 *  Created on: Sep 13, 2013
 *      Author: Ken Arok
 */

#include "config_board.h"

#if BOARD_2_1_USED

#ifndef BOARD_H_
#define BOARD_H_

#include "compiler.h"


/* CPU Frequency. */
#define F_CPU		14745600UL
//#define F_CPU		4000000UL

/* RTC Chip Name. */
#define RTC_PART_NAME_DS1307	1

/*
 PORT A
-----------------------------------------------------------------------------------------------------
|	PA7		|	PA6		|	PA5		|	PA4		|	PA3			|	PA2		|	PA1		|	PA0		|
-----------------------------------------------------------------------------------------------------
|	GPIO	|	GPIO	| 	GPIO	|	GPIO	|	MEGA162_CS	|	GPIO	|	GPIO	|	GPIO	|
-----------------------------------------------------------------------------------------------------
*/
#define GPIO_PINA7			PA7
#define GPIO_PINA6			PA6
#define GPIO_PINA5			PA5
#define GPIO_PINA4			PA4
#define GPIO_SPI_M162_CS	PA3
#define GPIO_PINA2			PA2
#define GPIO_PINA1			PA1
#define GPIO_PINA0			PA0

/*
 PORT B
-------------------------------------------------------------------------------------------------
|	PB7		|	PB6		|	PB5		|	PB4		|	PB3		|	PB2		|	PB1		|	PB0		|
-------------------------------------------------------------------------------------------------
|	GPIO	|	GPIO	| 	Buzzer	|	GPIO	|	MISO	|	MOSI	|	SCK		|	SS		|
-------------------------------------------------------------------------------------------------
*/
#define GPIO_PINB7			PB7
#define GPIO_PINB6			PB6
#define GPIO_BUZZER			PB5
#define GPIO_PINB4			PB4
#define GPIO_SPI_MISO		PB3
#define GPIO_SPI_MOSI		PB2
#define GPIO_SPI_SCK		PB1
#define GPIO_SPI_SS			PB0

/*
 PORTC
-------------------------------------------------------------------------------------------------
|	PC7		|	PC6		|	PC5		|	PC4		|	PC3		|	PC2		|	PC1		|	PC0		|
-------------------------------------------------------------------------------------------------
|	LCD_D7	|	LCD_D6	| 	LCD_D5	|	LCD_D4	|	LCD_RS	|	LCD_RW	|	LCD_E	|	NC		|
-------------------------------------------------------------------------------------------------
*/
#define GPIO_LCD_D7			PC7
#define GPIO_LCD_D6			PC6
#define GPIO_LCD_D5			PC5
#define GPIO_LCD_D4			PC4
#define GPIO_LCD_RS			PC3
#define GPIO_LCD_RW			PC2
#define GPIO_LCD_E			PC1

/*
 PORTD
-------------------------------------------------------------------------------------------------
|	PD7		|	PD6		|	PD5		|	PD4		|	PD3		|	PD2		|	PD1		|	PD0		|
-------------------------------------------------------------------------------------------------
|	GPIO	|	GPIO	| 	GPIO	|	GPIO	|	TX1		|	RX1		|	SDA		|	SCL		|
-------------------------------------------------------------------------------------------------
*/
#define GPIO_PIND7			PD7
#define GPIO_PIND6			PD6
#define GPIO_PIND5			PD5
#define GPIO_PIND4			PD4
#define GPIO_UART1_TX		PD3
#define GPIO_UART1_RX		PD2
#define GPIO_I2C_SDA		PD1
#define GPIO_I2C_SCL		PD0

/*
 PORTE
-----------------------------------------------------------------------------------------------------
|	PE7		|	PE6		|	PE5		|	PE4		|	PE3			|	PE2		|	PE1		|	PE0		|
-------------------------------------------------------------------------------------------------
|	GPIO	|	GPIO	| 	GPIO	|	GPIO	|	SDMMC_CS	|	LED_HB	|	TX0		|	RX0		|
----------------------------------------------------------------------------------------------------
*/
#define GPIO_PINE7			PE7
#define GPIO_PINE6			PE6
#define GPIO_PINE5			PE5
#define GPIO_PINE4			PE4
#define GPIO_SPI_MMC_CS		PE3
#define GPIO_LED_HB			PE2
#define GPIO_UART0_TX		PE1
#define GPIO_UART0_RX		PE0

/*
 PORTF
-------------------------------------------------------------------------------------------------
|	PF7		|	PF6		|	PF5		|	PF4		|	PF3		|	PF2		|	PF1		|	PF0		|
-------------------------------------------------------------------------------------------------
|	KEY		|	KEY		| 	KEY		|	KEY		|	KEY		|	KEY		|	KEY		|	KEY		|
-------------------------------------------------------------------------------------------------
*/
#define GPIO_KEY_COL1		PF7
#define GPIO_KEY_COL2		PF6
#define GPIO_KEY_COL3		PF5
#define GPIO_KEY_COL4		PF4
#define GPIO_KEY_ROW1		PF3
#define GPIO_KEY_ROW2		PF2
#define GPIO_KEY_ROW3		PF1
#define GPIO_KEY_ROW4		PE0

/*
 PORTG
-------------------------------------------------------------------------------------
|	-	|	-	|	-	|	PG4		|	PG3		|	PG2		|	PG1		|	PG0		|
-------------------------------------------------------------------------------------
|	-	|	-	| 	-	|	GPIO	|	GPIO	|	GPIO	|	LCD_BL	|	GPIO	|
-------------------------------------------------------------------------------------
*/
#define GPIO_PING4			PG4
#define GPIO_PING3			PG3
#define GPIO_PING2			PG2
#define GPIO_LCD_BLON		PG1
#define GPIO_PING0			PG0


/* LCD Port if it is used. */
#define LCD_PORT		PORTC_GPIO

/* Keypad Port if it is used. */
#define KEYPAD_PORT		PORTF_GPIO
#define KEYPAD_DDR		DDRF_GPIO
#define KEYPAD_PIN		PINF_GPIO


/*! \brief This function initializes the board target resources.
 */
extern void board_init(void);


#endif /* BOARD_H_ */

#endif /* BOARD_2_1_USED. */
